package logic

import (
	"context"
	"grpc.getaway.adminspro.padmins.com/internal/rpc/utils/database"
	"grpc.getaway.adminspro.padmins.com/pkg/config/businessError"
)

func GetInfo(ctx context.Context, id int64) (map[string]interface{}, *businessError.ErrorInfo) {
	if id <= 0 {
		return nil, businessError.AuthIdEmpty
	}

	row, e := database.Db.GetDefaultDb(ctx).Find("select * from admin where id=?", id)

	if e != nil {
		return nil, businessError.DbError(e)
	}

	if row == nil {
		return nil, businessError.AuthUserNotExits
	}

	return row, nil
}
